package com.vankimgps.activity;

import com.vankimgps.database.DatabaseHelper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class SettingsActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.settings_layout);
		
		Button btnLogout = (Button)findViewById(R.id.btnLogout);
		btnLogout.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				DatabaseHelper db = new DatabaseHelper(getApplication());
				db.setLogin(false);
				
				//open Login
				Intent intent = new Intent(getApplication(),LoginActivity.class);
				startActivity(intent);
				
				finish();
			}
		});
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    switch(item.getItemId())
	    {
	    case R.id.menu_tracking:{
			Intent intent = new Intent(this,TrackingActivity.class);				
			startActivity(intent);
			finish();
	    }
	        break;
	    case R.id.menu_finding:{
			Intent intent = new Intent(this,FindingActivity.class);				
			startActivity(intent);
			finish();
	    }
	        break;
	    case R.id.menu_aboutus:{
			Intent intent = new Intent(this,AboutUsActivity.class);				
			startActivity(intent);
			finish();
	    }
	        break;
	    }
	    return true;
	}
}